package com.ibiaoke.boss.controller;

import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.system.entity.XcxTopicPage;
import com.ibiaoke.system.entity.vo.XcxTopicPageVO;
import com.ibiaoke.system.service.XcxTopicPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 小程序的专题页
 */
@Controller
public class BossXcxTopicPageController extends BaseController {

    @Autowired
    private XcxTopicPageService xcxtopicPageService;

    /**
     *保存专题活动页
     * @param xcxTopicPageVO
     * @param bindingResult
     * @return
     */
    @RequestMapping("/saveXcxTopicPage")
    @ResponseBody
    public Res saveXcxTopicPage(@Validated XcxTopicPageVO xcxTopicPageVO, BindingResult bindingResult) {
        handleValidate(bindingResult);
        xcxtopicPageService.saveXcxTopicPage(xcxTopicPageVO);
        return Res.create();
    }

    /**
     * 修改专题活动页
     * @param xcxTopicPageVO
     * @return
     */
    @RequestMapping("/updateXcxTopicPage")
    @ResponseBody
    public Res updateXcxTopicPage(XcxTopicPageVO xcxTopicPageVO) {
        xcxtopicPageService.updateXcxTopicPage(xcxTopicPageVO);
        return Res.create();
    }

    /**
     * 查询专题活动页列表
     * @param position
     * @param page
     * @return
     */
    @RequestMapping("/listXcxTopicPage")
    @ResponseBody
    public Res listXcxTopicPage(Integer position,Integer showStatus, Page page) {
        List<XcxTopicPage> list = xcxtopicPageService.listXcxTopicPage(position,showStatus,page);
        return Res.create().addResponse("TopicPageList", list).addResponse("page", page);
    }


    /**
     * 获取专题活动页详情
     * @param xcxTopicPageId
     * @return
     */
    @RequestMapping("/getXcxTopicPage")
    @ResponseBody
    public Res getXcxTopicPage(Integer xcxTopicPageId) {
        XcxTopicPage topicPage = xcxtopicPageService.getXcxTopicPage(xcxTopicPageId);
        return Res.create().addResponse("topicPage", topicPage);
    }

    /**
     * 删除专题活动页
     * @param xcxTopicPageId
     * @return
     */
    @RequestMapping("/deleteXcxTopicPage")
    @ResponseBody
    public Res deleteXcxTopicPage(Integer xcxTopicPageId) {
        xcxtopicPageService.deleteXcxTopicPage(xcxTopicPageId);
        return Res.create();
    }
}
